<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../include/admincontent.jsp" %>

<div id="location">当前位置：首页 > 招聘方案管理 > 添加招聘方案</div>
<div id="Content">
    <form id="Validform" method="post" action="/Project/AddAction">
        <input type="hidden" id="proid" value="0"/>
        <div class="btnbar">
            <button type="submit" class="save">保 存</button>
            <button type="button" class="back" onclick="javascript:history.go(-1);">返 回</button>
        </div>
        <table class="treeTable inputform">
            <thead>
            <tr>
                <td colspan="4"><b>基本信息</b></td>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td width="65">方案名称：</td>
                <td>
                    <div style="width:300px;"><input type="text" name="project.pname" datatype="*" nullmsg="方案名称不能为空！"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td>招聘方式：</td>
                <td>
                    <div class="radio">
                        <span rel="1" fdata="1" class="checked">高校校园招聘</span>
                        <span rel="2" fdata="2">中专校园招聘</span>
                        <span rel="3" fdata="3">社会招聘</span>
                        <span rel="4" fdata="4">内部招聘</span>
                        <input type="hidden" id="recruittype" name="project.recruittype" value="1" datatype="*"
                               nullmsg="招聘方式不能为空！">
                    </div>
                </td>
            </tr>
            </tbody>
        </table>

        <!-- 高校校园招聘流程 -->
        <table class="treeTable inputform" style="margin-top:5px;" id="flow1">
            <thead>
            <tr>
                <td><b>实施流程</b></td>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>简历筛选&emsp;>&emsp;面试&emsp;>&emsp;背景调查&emsp;>&emsp;体检&emsp;>&emsp;岗位分配&emsp;>&emsp;录用</td>
            </tr>
            </tbody>
        </table>

        <!-- 中专校园招聘流程 -->
        <table class="treeTable inputform" style="margin-top:5px;display:none;" id="flow2">
            <thead>
            <tr>
                <td><b>实施流程</b></td>
            </tr>
            </thead>
            <tbody>
            <!-- <tr><td>毕业生推荐&emsp;>&emsp;初审&emsp;>&emsp;面试&emsp;>&emsp;投简历&emsp;>&emsp;背景调查&emsp;>&emsp;体检&emsp;>&emsp;岗位分配&emsp;>&emsp;实习&emsp;>&emsp;录用</td></tr> -->
            <tr>
                <td>毕业生推荐&emsp;>&emsp;初审&emsp;>&emsp;投简历&emsp;>&emsp;录用</td>
            </tr>
            </tbody>
        </table>

        <!-- 社会招聘流程 -->
        <table class="treeTable inputform" style="margin-top:5px; display:none;" id="flow3">
            <thead>
            <tr>
                <td colspan="4"><b>实施流程</b></td>
            </tr>
            <tr>
                <td width="80">流程顺序</td>
                <td width="200">流程内容</td>
                <td width="200">流程别名</td>
                <td>
                    <button type="button" onFocus="blur()" class="add"></button>
                </td>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>1</td>
                <td>简历筛选<input type="hidden" name="sflow[0].fid" value="0"/></td>
                <td>简历筛选<input type="hidden" name="sflow[0].nickname" value="简历筛选"/></td>
                <td></td>
            </tr>
            <tr>
                <td>2</td>
                <td>录用<input type="hidden" name="sflow[1].fid" value="7"/></td>
                <td>录用<input type="hidden" name="sflow[1].nickname" value="录用"/></td>
                <td></td>
            </tr>
            </tbody>
        </table>

        <!-- 内部招聘流程 -->
        <table class="treeTable inputform" style="margin-top:5px; display:none;" id="flow4">
            <thead>
            <tr>
                <td colspan="4"><b>实施流程</b></td>
            </tr>
            <tr>
                <td width="80">流程顺序</td>
                <td width="200">流程内容</td>
                <td width="200">流程别名</td>
                <td>
                    <button type="button" onFocus="blur()" class="add"></button>
                </td>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>1</td>
                <td>职位申请<input type="hidden" name="flow[0].fid" value="0"/></td>
                <td>职位申请<input type="hidden" name="flow[0].nickname" value="职位申请"/></td>
                <td></td>
            </tr>
            <tr>
                <td>2</td>
                <td>简历筛选<input type="hidden" name="flow[1].fid" value="1"/></td>
                <td>简历筛选<input type="hidden" name="flow[1].nickname" value="简历筛选"/></td>
                <td></td>
            </tr>
            <tr>
                <td>3</td>
                <td>录用<input type="hidden" name="flow[2].fid" value="4"/></td>
                <td>录用<input type="hidden" name="flow[2].nickname" value="录用"/></td>
                <td></td>
            </tr>
            </tbody>
        </table>

        <!-- 高校校园招聘地区 -->
        <table class="treeTable inputform" id="areagx" style="margin-top:5px;">
            <thead>
            <tr>
                <td><b>招聘地区</b></td>
            </tr>
            </thead>
            <tbody id="arearst">
            <tr>
                <td>
                    <div class=radio1>${areas}</div>
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        showJobList($('#recruittype').val());
        //选择招聘方式
        $('.radio span').click(function () {
            $('table[id^=flow]').hide();
            $('#flow' + $(this).attr('fdata')).show();
            showJobList($(this).attr('fdata'));
        });

        //添加内部招聘流程
        $(document).delegate('#flow4 button.add', 'click', function () {

            var temp = '<tr><td>2</td><td><div><select><option value="2">面试</option><option value="3">笔试</option></select></div></td>';
            temp += '<td><div><input type="text" value="面试" datatype="*" nullmsg="流程别名不能为空！"></div></td>';
            temp += '<td><button type="button" onfocus="blur()" class="del"></button></td></tr>';

            $('#flow4 tbody tr:last').before(temp);
            setFlowStyle();
        });

        //添加社会招聘流程
        $(document).delegate('#flow3 button.add', 'click', function () {

            var temp = '<tr><td>2</td><td><div><select name="sflow[1].fid"><option value="1">笔试</option><option value="2">资料审核</option><option value="3">面试</option><option value="4">实作</option><option value="5">体检</option><option value="6">背景调查</option></select></div></td>';
            temp += '<td><div><input type="text" name="sflow[1].nickname" datatype="*" nullmsg="流程别名不能为空！"></div></td>';
            temp += '<td><button type="button" onfocus="blur()" class="del"></button></td></tr>';

            $('#flow3 tbody tr:last').before(temp);
            $('#flow3 tbody tr:last').prev().find('td:eq(2) input').val($('#flow3 tbody tr:last').prev().find('td:eq(1) select option:checked').text());
            setFlowStyle();
        });

        //删除流程
        $(document).delegate('#flow3 button.del,#flow4 button.del', 'click', function () {
            $(this).parent().parent().remove();
            setFlowStyle();
        });

        //流程别名
        $(document).delegate('#flow3 select,#flow4 select', 'change', function () {
            $(this).parent().parent().next().find('input').val($(this).find('option:checked').text());
            $(this).prev().val($(this).val());
        });

        //删除招聘岗位
        $(document).delegate('#jobtb button.del', 'click', function () {
            $(this).parent().parent().remove();
            setJobStyle();
        });

        //招聘地区
        $(document).delegate('.inputform tbody div.radio1 span', 'click', function () {
            $(this).parent().find('input[type=hidden]').remove();
            if (!$(this).parent().hasClass('disables')) {
                if ($(this).hasClass('checked'))
                    $(this).removeClass('checked');
                else
                    $(this).addClass('checked');
                var i = 0;
                $(this).parent().find('span').each(function () {
                    if ($(this).hasClass('checked')) {
                        $(this).parent().append('<input type="hidden" name="region[' + i + '].rcode" value="' + $(this).attr('rel') + '" />');
                        $(this).parent().append('<input type="hidden" name="region[' + i + '].region" value="' + $(this).text() + '" />');
                        i++;
                    }
                });
            }
        });

    });

    //设置流程表单信息
    function setFlowStyle() {
        //社会招聘
        $('#flow3 tbody tr').each(function (index) {
            $(this).find('td:first').html(index + 1);
            if (index > 0 && index < $('#flow3 tbody tr').length - 1) {
                $(this).find('td:eq(1) select').attr('name', 'sflow[' + index + '].fid');
                $(this).find('td:eq(2) input').attr('name', 'sflow[' + index + '].nickname');
            } else {
                $(this).find('td:eq(1) input').attr('name', 'sflow[' + index + '].fid');
                $(this).find('td:eq(2) input').attr('name', 'sflow[' + index + '].nickname');
            }
        });

        //内部招聘
        $('#flow4 tbody tr').each(function (index) {
            $(this).find('td:first').html(index + 1);
            if (index > 1 && index < $('#flow4 tbody tr').length - 1) {
                $(this).find('td:eq(1) select').attr('name', 'flow[' + index + '].fid');
                $(this).find('td:eq(2) input').attr('name', 'flow[' + index + '].nickname');
            } else {
                $(this).find('td:eq(1) input').attr('name', 'flow[' + index + '].fid');
                $(this).find('td:eq(2) input').attr('name', 'flow[' + index + '].nickname');
            }
        });
    }

    //设置岗位表单信息
    function setJobStyle() {
        $('#result tr').each(function (index) {
            $(this).find('td:first span').html(index + 1);
            $(this).find('td:first input').attr('name', 'job[' + index + '].did');
            $(this).find('td:eq(8) input').attr('name', 'job[' + index + '].zpcount');
        });
    }

    //显示或隐藏岗位列表
    function showJobList(str) {
        if (str == '1') {
            $('#areagx').show();
        } else {
            $('#areagx').hide();
        }
    }

</script>
</body>
</html>